<html>
<head><meta charset="utf-8"><title>Can we have a Integer supertrait? · general · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/index.html">general</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20we.20have.20a.20Integer.20supertrait.3F.html">Can we have a Integer supertrait?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="196274577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20we%20have%20a%20Integer%20supertrait%3F/near/196274577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20we.20have.20a.20Integer.20supertrait.3F.html#196274577">(May 05 2020 at 07:18)</a>:</h4>
<p>Hi,<br>
How do people feel/think about an Integer supertrait? that will contain <code>max_value</code> and <code>min_value</code> and will probably depend on a lot of the arithmetic traits too</p>



<a name="196274601"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20we%20have%20a%20Integer%20supertrait%3F/near/196274601" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Elichai Turkel <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20we.20have.20a.20Integer.20supertrait.3F.html#196274601">(May 05 2020 at 07:19)</a>:</h4>
<p>This kind of "trait" is very commonly used in C++</p>



<a name="196275626"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122651-general/topic/Can%20we%20have%20a%20Integer%20supertrait%3F/near/196275626" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Hanna Kruppe <a href="https://rust-lang.github.io/zulip_archive/stream/122651-general/topic/Can.20we.20have.20a.20Integer.20supertrait.3F.html#196275626">(May 05 2020 at 07:34)</a>:</h4>
<p>There's an absolutely enormous design space for numeric traits (hierarchies), I would even say there is no single best design for it. libstd is a bad place to explore that kind of space since it's constrained by backwards compatibility and generally wants to be small/focused. There's the <code>num-traits</code> crate and some other crates that address this subject and don't have those constraints.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>